import axios from 'axios';
import {takeEvery, call, put} from 'redux-saga/effects'

export default function *watchMiddleware(){
    yield takeEvery('change-cinemaList', getCinemaList);
}

function *getCinemaList(){
    let res = yield call(cinemListAction);
    yield put({
        type:'get-cinemaList',
        value:res
    })
}

function cinemListAction(){
    return axios({
        url:'https://m.maizuo.com/gateway?cityId=440300&ticketFlag=1&k=5422816',
        headers:{
            'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"165294070798642513887233"}',
            'X-Host': 'mall.film-ticket.cinema.list'
        }
    }).then(res =>{
        return res.data.data.cinemas;
    })
}